<?php
	
	session_start();
	require_once('common/config.php');
	
	if(!isset($_SESSION['logon']))
	{
		header("Location: /wks/login.php?url=ads");
		exit();
	}
	
	if(!defined('BASE_DIR'))
	  define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']) ;
	  
	$pageCMS = PAGE_CMS_ADS;
	$ads = simplexml_load_file(BASE_DIR."/xml/ads.xml");
	
	if(!isset($_POST['submit'])){
		require_once('template/banner/ads_view.php');
		exit();
	}
	else
	{
		$ads->item1->link = $_POST['ads_link1'] != ''?$_POST['ads_link1'] : '#';
		$ads->item1->image = $_POST['ads_img1'];
		
		$ads->item2->link = $_POST['ads_link2'] != ''?$_POST['ads_link2'] : '#';
		$ads->item2->image = $_POST['ads_img2'];
		
		$ads->item3->link = $_POST['ads_link3'] != ''?$_POST['ads_link3'] : '#';
		$ads->item3->image = $_POST['ads_img3'];
		
		$ads->item4->link = $_POST['ads_link4'] != ''?$_POST['ads_link4'] : '#';
		$ads->item4->image = $_POST['ads_img4'];
		
		$ads->asXML(BASE_DIR."/xml/ads.xml");
		header("Location: /wks/ads.php");
	}
?>


